package com.cn.fw4j.container.impl;

import java.util.LinkedHashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cn.fw4j.container.inter.IContainerObserver;
import com.cn.fw4j.jdbc.annotation.dao.Fw4jDao;
import com.cn.fw4j.util.ParseClassPackageHelper;


public class DaoContainer implements IContainerObserver {
	
	private final static Logger logger = LoggerFactory.getLogger(DaoContainer.class);

	private Map<String,String> daos = new LinkedHashMap<String,String>();
	
	@Override
	public void add(String path) {
		if(path.endsWith(".class") && path.indexOf("bin-groovy") == -1) {
			try {
				logger.info(path);
				String name = ParseClassPackageHelper.getPackage(path).replace("/", ".");
				Class<?> cl = Thread.currentThread().getContextClassLoader().loadClass(name);
				Fw4jDao dao = cl.getAnnotation(Fw4jDao.class);
				if(dao!=null){
					createDaoImpl(cl);
				}
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
	}
	
	private void createDaoImpl(Class<?> cl){
		
	}
}
